//
//  HWAppointmentRankProtocol.swift
//  HWanGame
//
//  Created by 王昌健 on 2022/3/10.
//  Copyright © 2022 94Wan. All rights reserved.
//

import UIKit

class HWAppointmentRankProtocol: NSObject {
    var models:[HWAppointmentRankModel]?
    var didClickItem:((_:HWAppointmentRankModel)->())?
    var appointmentButtonClick:((_:String)->())?
}

extension HWAppointmentRankProtocol:UITableViewDelegate,UITableViewDataSource {
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        didClickItem?(models![indexPath.row])
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return models?.count ?? 0
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = HWAppointmentRankCell.cellWithTableView(tableView: tableView)
        cell.indexPath = indexPath
        cell.model = models?[indexPath.row]
        cell.appointmentButtonClick = {
            self.appointmentButtonClick?($0)
        }
        return cell
    }
    
    
}
